// part1:C09:ex9.31.cpp
// delete even elements and copy odd elements.
#include <iostream>
#include <list>

int main(void) {
  using namespace std;
  list<int> ilis = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  auto curr = ilis.begin();

  while (curr != ilis.end()) {
    if (*curr & 1) {
      curr = ilis.insert(curr, *curr);
      curr++;
      curr++;
    } else {
      curr = ilis.erase(curr);
    }
  }

  for (curr = ilis.begin(); curr != ilis.end(); curr++) {
    cout << *curr << " "; 
  }
  cout << endl;

  return 0;
}
